{
 "metadata": {
  "name": "",
  "signature": "sha256:38c79161a4ef765f3379da5122f6478a1143c9d39924d44cc57aff7c75a31629"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "# Zhenfeng Liang"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "# MTH9879 Homework 9\n",
      "\n",
      "Assigned: April 21, 2015.\n",
      "Due: May 5, 2015 by 6pm. \n",
      "\n",
      "Late homework **will not be accepted**.\n",
      "\n",
      "$$\n",
      "\\newcommand{\\supp}{\\mathrm{supp}}\n",
      "\\newcommand{\\E}{\\mathbb{E}}\n",
      "\\newcommand{\\Eof}[1]{\\mathbb{E}\\left[ #1 \\right]}\n",
      "\\def\\Cov{{ \\mbox{Cov} }}\n",
      "\\def\\Var{{ \\mbox{Var} }}\n",
      "\\newcommand{\\1}{\\mathbf{1} }\n",
      "\\newcommand{\\PP}{\\mathbb{P} }\n",
      "%\\newcommand{\\Pr}{\\mathrm{Pr} }\n",
      "\\newcommand{\\QQ}{\\mathbb{Q} }\n",
      "\\newcommand{\\RR}{\\mathbb{R} }\n",
      "\\newcommand{\\DD}{\\mathbb{D} }\n",
      "\\newcommand{\\HH}{\\mathbb{H} }\n",
      "\\newcommand{\\spn}{\\mathrm{span} }\n",
      "\\newcommand{\\cov}{\\mathrm{cov} }\n",
      "\\newcommand{\\sgn}{\\mathrm{sgn} }\n",
      "\\newcommand{\\HS}{\\mathcal{L}_{\\mathrm{HS}} }\n",
      "%\\newcommand{\\HS}{\\mathrm{HS} }\n",
      "\\newcommand{\\trace}{\\mathrm{trace} }\n",
      "\\newcommand{\\LL}{\\mathcal{L} }\n",
      "%\\newcommand{\\LL}{\\mathrm{L} }\n",
      "\\newcommand{\\s}{\\mathcal{S} }\n",
      "\\newcommand{\\ee}{\\mathcal{E} }\n",
      "\\newcommand{\\ff}{\\mathcal{F} }\n",
      "\\newcommand{\\hh}{\\mathcal{H} }\n",
      "\\newcommand{\\bb}{\\mathcal{B} }\n",
      "\\newcommand{\\dd}{\\mathcal{D} }\n",
      "\\newcommand{\\g}{\\mathcal{G} }\n",
      "\\newcommand{\\p}{\\partial}\n",
      "\\newcommand{\\half}{\\frac{1}{2} }\n",
      "\\newcommand{\\T}{\\mathcal{T} }\n",
      "\\newcommand{\\bi}{\\begin{itemize}}\n",
      "\\newcommand{\\ei}{\\end{itemize}}\n",
      "\\newcommand{\\beq}{\\begin{equation}}\n",
      "\\newcommand{\\eeq}{\\end{equation}}\n",
      "\\newcommand{\\beas}{\\begin{eqnarray*}}\n",
      "\\newcommand{\\eeas}{\\end{eqnarray*}}\n",
      "\\newcommand{\\cO}{\\mathcal{O}}\n",
      "\\newcommand{\\cC}{\\mathcal{C}}\n",
      "\\newcommand{\\cF}{\\mathcal{F}}\n",
      "\\newcommand{\\cL}{\\mathcal{L}}\n",
      "\\newcommand{\\BS}{\\text{BS}}\n",
      "$$"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<font color = \"red\">Homework is to be done by each student individually.  To receive full credit, you must email a completed copy of this iPython notebook to Yu Gan (yugan323@gmail.com), Fubo Shi (fubo.shi.baruch@gmail.com), and Tai-Ho Wang (tai-ho.wang@baruch.cuny.edu) by the due date and time.  All R-code must run correctly and solutions must be written up neatly in Markdown/LaTeX format.\n",
      "\n",
      "<font color=\"blue\">If you encounter problems with Markdown/LaTeX or iPython notebook, please contact your TAs Yu Gan and/or Fubo Shi.\n"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### 1. (12 points)\n",
      "Following Almgren and Chriss,  assume that the stock price $S_t$ evolves as\n",
      "\n",
      "$$\n",
      "dS_t = \\sigma\\,dZ_t\n",
      "$$\n",
      "\n",
      "and the price $\\tilde S_t$ at which we transact is given by\n",
      "\n",
      "$$\n",
      "\\tilde S_t = S_t - \\eta\\,v_t\n",
      "$$\n",
      "\n",
      "where $v_t:=-{\\dot x}_t$ is the rate of trading with $x_0 = X$ and $x_T = 0$.\n",
      "\n",
      "In the lecture slides, we showed that with a risk term that penalizes average VaR instead of variance, the risk-adjusted cost of trading associated with a given price path $\\{S_t\\}$ is given by\n",
      "\n",
      "$$\n",
      "C = \\int_0^T\\,(S_t - \\eta\\,v_t) dx_t + \\lambda\\,\\sigma\\,\\int_0^T\\,x_t\\,dt\n",
      "$$\n",
      "\n",
      "for some price of risk $\\lambda$. We want to find a (possibly state-dependent) control $v_t$ that minimizes the expected cost $\\cC=\\E[C]$.\n",
      "\n",
      "(a) Apply the technique of integration by parts to simplify the term $\\int_0^T S_t dx_t$. Write down the HJB equation for the resulting problem.\n",
      "\n",
      "(b) Solve the first order condition to find the optimal trading rate $v^\\star$.    \n",
      "\n",
      "(c) Substitute $v^\\star$ back into the HJB equation to show that the value function $\\cC$ must satisfy\n",
      "$$\n",
      "\\cC_t = \\frac{\\cC_x^2}{4\\,\\eta\\,} - \\lambda \\sigma x.\n",
      "$$\n",
      "\n",
      "(d) With the terminal condition, \n",
      "$$\\lim_{t\\uparrow T}\\cC(t,x) = \\begin{cases}0&\\text{if $x=0$,}\\\\\n",
      "+\\infty&\\text{if $x\\neq0$.}\n",
      "\\end{cases}$$\n",
      "solve the HJB equaiton with the ansatz $\\cC(t,x) = a(t)x^2 + b(t)x + c(t)$. Verify that the optimal trading strategy with liquidation horizon set to the characteristic time is given by\n",
      "\\begin{eqnarray*}\n",
      "x_t&=&X\\,\\left(1-\\frac{t}{T}\\right)^2.\n",
      "\\end{eqnarray*}\n",
      "Recall that with the notation of the lecture slides, the characteristic time is defined as\n",
      "$$\n",
      "T^\\star=\\sqrt{\\frac{2\\,X}{A}}=\\sqrt{\\frac{4\\,\\eta\\,X}{\\lambda\\,\\sigma}}\n",
      "$$\n",
      "Compute the risk-adjusted cost function $\\cC$ associated with this strategy. \n"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Solution:\n",
      "\n",
      "### (a)\n",
      "\n",
      "\\begin{eqnarray*}\n",
      "\\int_0^T S_t dx_t &=& \\int_0^T \\sigma W_t dx_t \\\\\n",
      "&=& \\sigma  x_t W_t |_0^T - \\int_0^T \\sigma x_t d W_t \\\\\n",
      "&=& - \\int_0^T \\sigma x_t d W_t\n",
      "\\end{eqnarray*}\n",
      "\n",
      "Therefore we have, \n",
      "\n",
      "\\begin{eqnarray*}\n",
      "\\cC=\\E[C] &=& \\E[\\lambda\\,\\sigma\\,\\int_0^T\\,x_t\\,dt - \\int_0^T \\sigma x_t d W_t - \\int_0^T\\,\\eta\\,v_t dx_t] \\\\\n",
      "&=& \\lambda\\,\\sigma\\,\\int_0^T\\,x_t\\,dt - \\int_0^T\\,\\eta\\,v_t dx_t \\\\\n",
      "&=& \\lambda\\,\\sigma\\,\\int_0^T\\,x_t\\,dt + \\int_0^T\\,\\eta\\,v_t^2 d t\n",
      "\\end{eqnarray*}\n",
      "\n",
      "The value functiion $C$ is\n",
      "$$\n",
      "C(t,x) = \\min_{v\\in\\mathcal G[t,T]} \\left\\{\\lambda\\,\\sigma\\,\\int_0^T\\,x_t\\,dt + \\int_0^T\\,\\eta\\,v_t^2 d t \\right\\}\n",
      "$$\n",
      "\n",
      "The running cost $h(t,x,v) = \\lambda\\,\\sigma\\, x_t + \\eta\\,v_t^2$\n",
      "\n",
      "The infinitesimal generator is \n",
      "\n",
      "$$\\mathcal L^{(v)} C(t,x) = (\\frac{\\sigma^2}2 \\p_x^2 + \\mu \\p_x)C(t,x) = -v\\,C_x$$\n",
      "\n",
      "The HJB equation reads\n",
      "\n",
      "$$\\frac{\\partial C}{\\partial t} + \\lambda\\,\\sigma\\,x + \\min_{v \\in \\mathcal{G}}\\left\\{-v\\,C_x + \\eta\\,v^2\\right\\}=0.$$"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### (b)\n",
      "\n",
      "From (a), we know we have to minimize,\n",
      "\n",
      "$\\left\\{-v\\,C_x + \\eta\\,v^2\\right\\}$, which is a quardratic function. \n",
      "\n",
      "We know when \n",
      "\n",
      "$$\n",
      "v = \\frac{C_x}{2\\eta}\n",
      "$$\n",
      "\n",
      "it is minimized."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### (c)\n",
      "\n",
      "If we plug the above formula into the HJB equation, we got,\n",
      "\n",
      "$$\\frac{\\partial C}{\\partial t} + \\lambda\\,\\sigma\\,x - \\frac{C_x^2}{4\\eta}=0.$$\n",
      "\n",
      "Therefore, we have,\n",
      "\n",
      "$$\n",
      "\\cC_t = \\frac{\\cC_x^2}{4\\,\\eta\\,} - \\lambda \\sigma x.\n",
      "$$"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### (d)\n",
      "\n",
      "We plug $\\cC(t,x) = a(t)x^2 + b(t)x + c(t)$ into the above formula, we have,\n",
      "\n",
      "$$\n",
      "(a' - \\frac{a^2}{\\eta})x^2 + (b' - \\frac{ab}{\\eta} + \\lambda \\sigma)x + (c' - \\frac{b^2}{4\\eta}) = 0\n",
      "$$\n",
      "\n",
      "Setting the coefficient to be $0$,\n",
      "\\begin{eqnarray*}\n",
      "a' &=& \\frac{a^2}{\\eta} \\\\\n",
      "b' &=& \\frac{ab}{\\eta} - \\lambda \\sigma \\\\\n",
      "c' &=& \\frac{b^2}{4\\eta}\n",
      "\\end{eqnarray*}\n",
      "\n",
      "Taking into account the terminal condition, we obtain the solution for $a$, $b$ and $c$ which are not unique as,\n",
      "\n",
      "We could easily get \n",
      "$$\n",
      "a = -\\frac{\\eta}{t - T}\n",
      "$$\n",
      "\n",
      "Plug this into $b$, we need to solve,\n",
      "\n",
      "$$\n",
      "b' + \\frac{b}{t-T} = -\\lambda \\sigma\n",
      "$$\n",
      "\n",
      "which is First order linear non-homogeneous ordinary differential equation, solve it, we got,\n",
      "\n",
      "$$\n",
      "b = \\frac{Const_b}{t - T} - \\frac{\\lambda\\sigma}{2}\\frac{t^2 - 2Tt}{t-T}\n",
      "$$\n",
      "\n",
      "We couldn't determine $Const_b$ at this point.\n",
      "\n",
      "We plug it into the third equation, with some rearrangement, we could have,\n",
      "\n",
      "$$\n",
      "c' = \\frac{1}{4\\eta}\\frac{(\\frac{\\lambda\\sigma}{2}(t^2 - 2Tt) - Const_b)^2}{(t-T)^2}\n",
      "$$\n",
      "\n",
      "To simplify the formula, we set $Const_b = -\\frac{\\lambda\\sigma}{2}T^2$, we could have,\n",
      "\n",
      "$$\n",
      "c' = \\frac{(\\lambda \\sigma)^2}{16\\eta}\n",
      "$$\n",
      "\n",
      "Considering the terminal condition, $C(T,0) = 0$, we have,\n",
      "\n",
      "$$\n",
      "c = \\frac{(\\lambda \\sigma)^2}{16\\eta}t - \\frac{(\\lambda \\sigma)^2}{16\\eta}T\n",
      "$$\n",
      "\n",
      "Therefore, we have,\n",
      "\n",
      "\\begin{eqnarray*}\n",
      "a &=& -\\frac{\\eta}{t - T} \\\\\n",
      "b &=& -\\frac{\\lambda\\sigma}{2}\\frac{T^2}{t - T} - \\frac{\\lambda \\sigma}{2}\\frac{t^2 - 2Tt}{t - T} = -\\frac{\\lambda \\sigma}{2}(t-T)\\\\\n",
      "c &=& \\frac{(\\lambda \\sigma)^2}{16\\eta}(t - T)\n",
      "\\end{eqnarray*}\n",
      "\n",
      "Hence, the optimal trading rate is \n",
      "$$\n",
      "v = \\frac{C_x}{2\\eta} = -\\frac{x}{t-T} - \\frac{\\lambda\\sigma}{4\\eta}(t-T) = -\\dot x\n",
      "$$\n",
      "\n",
      "Solve it, we got,\n",
      "\n",
      "$$\n",
      "x_t = (\\frac{\\lambda\\sigma}{4\\eta}t + const)(t - T)\n",
      "$$\n",
      "\n",
      "We plug initial value into the formula, we have,\n",
      "\n",
      "$$\n",
      "x_0 = -T const = X\n",
      "$$\n",
      "\n",
      "So we have,\n",
      "\n",
      "\\begin{eqnarray*}\n",
      "x_t &=& (\\frac{\\lambda\\sigma}{4\\eta}t - \\frac{X}{T})(t - T) \\\\\n",
      "&=& (X - \\frac{\\lambda\\sigma}{4\\eta}Tt)(1 - \\frac{t}{T}) \\\\\n",
      "&=& X(1 - \\frac{\\lambda\\sigma}{4X\\eta}Tt)(1 - \\frac{t}{T})\n",
      "\\end{eqnarray*}\n",
      "\n",
      "We chose $T = T^\\star$\n",
      "$$\n",
      "T^\\star=\\sqrt{\\frac{4\\,\\eta\\,X}{\\lambda\\,\\sigma}}\n",
      "$$\n",
      "\n",
      "Thereofore, we have,\n",
      "$$\n",
      "x_t = X(1 - \\frac{t}{T^\\star})^2 = X(1 - \\frac{t}{T})^2\n",
      "$$\n",
      "\n",
      "So, we have,\n",
      "\n",
      "\\begin{eqnarray*}\n",
      "E[C] &=& \\lambda\\,\\sigma\\,\\int_0^T\\,x_t\\,dt + \\int_0^T\\,\\eta\\,v_t^2 d t  \\\\\n",
      "&=& X(\\lambda \\sigma + \\frac{4\\eta X}{T^2}) \\int_0^T (1 - \\frac{t}{T})^2 d t \\\\\n",
      "&=& \\frac{XT}{3}(\\lambda \\sigma + \\frac{4\\eta X}{T^2})\n",
      "\\end{eqnarray*}"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## ABM and GBM"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### Set up R environment"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%load_ext rmagic"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%R\n",
      "library(highfrequency)\n",
      "download.file(url=\"http://mfe.baruch.cuny.edu/wp-content/uploads/2015/03/MSFT130311.rData_.zip\", destfile=\"MSFT130311.zip\")\n",
      "unzip(zipfile=\"MSFT130311.zip\")\n",
      "load(\"MSFT130311.rData\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "display_data",
       "text": [
        "Loading required package: xts\n",
        "Loading required package: zoo\n",
        "\n",
        "Attaching package: \u2018zoo\u2019\n",
        "\n",
        "The following objects are masked from \u2018package:base\u2019:\n",
        "\n",
        "    as.Date, as.Date.numeric\n",
        "\n",
        "trying URL 'http://mfe.baruch.cuny.edu/wp-content/uploads/2015/03/MSFT130311.rData_.zip'\n",
        "Content type 'application/zip' length 71919 bytes (70 Kb)\n",
        "opened URL\n",
        "==================================================\n",
        "downloaded 70 Kb\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### 2. (8 points)\n",
      "\n",
      "Recall from the lecture slides that with time-averaged VaR as the risk penalty, and when the liquidation time $T$ is chosen to be the characteristic time, the optimal trading rate under ABM becomes\n",
      "\n",
      "$$\n",
      "v^A(t)= \\frac{x_t}{T-t}\\,+\\frac{X}{T}\\,\\left(1-\\frac t T\\right)\n",
      "$$\n",
      "\n",
      "and the optimal trading rate under GBM becomes\n",
      "\n",
      "$$\n",
      "v^G(t)= \\frac{x_t}{T-t}\\,+\\frac{X}{T}\\,\\frac{S_t}{S_0}\\,\\left(1-\\frac t T\\right).\n",
      "$$\n",
      "\n",
      "(a) The *msft.bats* dataset from *MSFT130311.rData* contains all trades on the BATS exchange on 11-Mar-2013.  One trading days has 390 minutes.  Sample the  *msft.bats* dataset evenly, roughly every minute of volume time.  Superimpose plots of the optimal strategy under ABM and GBM assuming liquidation takes place over one trading day.\n",
      "\n",
      "(b) Denote the corresponding position sizes by $x^A(t)$ and $x^G(t)$ respectively.  What is the maximum deviation of the two position sizes as a percentage of the initial position $X$?  How significant is this deviation?\n",
      "\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%R\n",
      "\n",
      "# Get access to the data\n",
      "data <- msft130311.bats\n",
      "\n",
      "# Implement the optimal trading rate functions under two assumptions.\n",
      "Cal_V_A <- function(xt, t){xt/(T-t) + X/T*(1 - t/T)}\n",
      "Cal_V_G <- function(xt, t, St){xt/(T-t) + X/T * St/S0 * (1 - t/T)}"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 3
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%R\n",
      "\n",
      "# Time steps to sample\n",
      "Steps <- 390\n",
      "\n",
      "# Initial shares to liquidate\n",
      "X <- 1000\n",
      "\n",
      "# Price of risk\n",
      "lambda <- 0.001\n",
      "\n",
      "# Compute the total volume\n",
      "volume <- data$signed.shares\n",
      "vol_minute <- round(sum(abs(volume))/Steps)\n",
      "\n",
      "# Sample the share price based on the volume time\n",
      "S_t <- data$trade.price[!duplicated(floor(cumsum(abs(volume))/vol_minute))]\n",
      "\n",
      "# Initial price when I begin to liquidate\n",
      "S0 <- S_t[1]\n",
      "\n",
      "# Characteristic time\n",
      "T <- sqrt(4*X/(lambda * S0))\n",
      "#T <- Steps\n",
      "\n",
      "# Position sizes\n",
      "X_A <- rep(0, Steps)\n",
      "X_G <- rep(0, Steps)\n",
      "X_A[1] <- X\n",
      "X_G[1] <- X\n",
      "\n",
      "# trading rate at each time step\n",
      "V_A <- rep(0, Steps)\n",
      "V_G <- rep(0, Steps)\n",
      "\n",
      "for(i in 1:(Steps-1))\n",
      "{\n",
      "    V_A[i] <- Cal_V_A(X_A[i], i)\n",
      "    X_A[i+1] <- X_A[i] - V_A[i]\n",
      "    \n",
      "    V_G[i] <- Cal_V_G(X_G[i], i, S_t[i])\n",
      "    X_G[i+1] <- X_G[i] - V_G[i]\n",
      "    \n",
      "#    cat(V_A[i], \",\", V_G[i], \"\\n\")\n",
      "#    cat(X_A[i+1], \",\", X_G[i+1], \"\\n\")\n",
      "}\n",
      "\n",
      "t <- seq(0,Steps - 1)\n",
      "\n",
      "plot(t,V_A,col=\"red\",type=\"l\", ylab = expression(\"Trading rate\"), xlab = expression(\"minute based on volume time\"))\n",
      "\n",
      "lines(t,V_G,main=\"Optimal trading rate under two assumptions\", col=\"blue\", type=\"l\")\n",
      "\n",
      "legend(\"topright\", c(\"ABM\",\"GBM\"),\n",
      "           lty = c(1,1), col=c(\"red\",\"blue\"))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgCAIAAADytinCAAAgAElEQVR4nO3deUCM6QMH8Gemqem+\n0an7QBLlqNz6oeiQUrmPcpTFui1Li10sdt33mSiiROWMlih3sbtFUoTSTaJ0zO+P2S2b5GrmeWfm\n+/lr5p2Z9/32sN99vT3zvCwej0cAAIB52LQDAABA41DQAAAMhYIGAGAoFDQAAEOhoAEAGAoFDQDA\nUChoAACGQkEDADAUChoAgKFQ0AAADIWCBgBgKBQ0AABDoaABABgKBQ0AwFAoaAAAhkJBAwAwFAoa\nAIChUNAAAAyFggYAYCgUNAAAQ6GgAQAYCgUNAMBQKGgAAIZCQQMAMBQKGgCAoVDQAAAMhYIGAGAo\nFDQAAEOhoAEAGAoFDQDAUChoAACGQkEDADAUChoAgKFQ0AAADIWCBgBgKBQ0AABDoaABABgKBQ0A\nwFAoaAAAhkJBAwAwFAoaAIChUNAAAAyFggYAYCgUNAAAQ6GgAQAYCgUNAMBQKGgAAIZCQQMAMBQK\nGgCAoVDQAAAMhYIGAGAoFDQAAEOhoAEAGAoFDQDAUChoAACGQkEDADAUChoAgKE4tAN8maKiosjI\nSB6PRzsIAAAhhHC53OHDh0tLSwti5yJ2Bh0fH5+QkEA7BQB8lqysrMjISNopBGvnzp2JiYkC2rmI\nnUETQhwdHSdOnEg7BQB82rVr13g8nnj/B3v9+nXB7VzEzqABACQHChoAgKFQ0AAADIWCBgBgKBQ0\nAABDoaABABgKBQ0AwFAoaAAAhkJBA4D44/F4FhYWmpqaVVVV/C2vX79m/UtaWtrOzi45OZkQkpeX\nx2Kxxo8f//7HAwMDWSxWdna2kGOjoAFA/N25c+fVq1eqqqoXLlx4f3t2dnZJSUl2dnb//v19fHz4\n6/xwOJxTp07VVXltbe3Jkye5XK7wY4tzQZ/88XptVQ3tFABAX1hY2MiRI319fcPD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Ts7AwGDmzJnLli178OBBWFjYpEmTWrdu\nbWFh0bFjx44dO44ePVpHR+fDPTs6Oi5evNjb27tTp04+Pj4KCgrvH8vExGTnzp2TJ082MDAoKSnZ\nsmXL5/yA5ubmKioqrq6u0tLSn9zJx0ajCY3+IO/jj2R5eXmz7A1EBevDK4YAAMAEOIMGAGAoFDQA\nAEOhoAEAGAoFDQDAUChoAACGQkEDADAUChoAgKFQ0AAADIWCBgBgKBQ0AABDoaABABgKBQ0AwFAo\naAAAhkJBAwAwFAoaAIChUNAAAAyFggYAYCgUNAAAQ/0f2BpmAxstDw4AAAAASUVORK5CYII=\n"
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%%R\n",
      "\n",
      "# (b)\n",
      "max_diff <- max(abs(X_A - X_G))\n",
      "deviation <- max_diff / X\n",
      "message(paste(\"the maximum deviation of the two position sizes as a percentage of the initial position X =\",deviation*100, \" %\"))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "display_data",
       "text": [
        "the maximum deviation of the two position sizes as a percentage of the initial position X = 0.122978884800318  %\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Appearantly, 0.123% is very insignificant."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Kratz and Sch\u00f6neborn with time-averaged VaR risk charge"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### 3. (16 points)\n",
      "\n",
      "(a) Repeat the computation of the optimal strategy from the lecture slides with time-averaged VaR\n",
      "\n",
      "$$\n",
      "\\lambda\\,\\sigma\\,\\int_0^T\\,x_t\\,dt\n",
      "$$\n",
      "\n",
      "as the risk term (rather than the quadratic variation $\\lambda\\,\\sigma^2\\,\\int_0^T\\,x_t^2\\,dt$).  Show that the optimal position\n",
      "\n",
      "$$\n",
      "x^\\star(t)=\\left(X-\\frac{A\\, T}{\\theta }\\right)\\,\\frac{1-e^{-\\theta\\,(T-t)} }{1-e^{-\\theta\\,T }}+\\frac{A }{\\theta }\\,(T-t)\n",
      "$$\n",
      "and deduce the optimal trading rate $v^\\star(t)$.\n",
      "\n",
      "(b) By Taylor-expanding the solution around $\\theta=0$, show that we retrieve the solution derived in the slides with no dark pool\n",
      "\n",
      "$$\n",
      "x^\\star(t)=\\left(X-\\frac{A \\, T}{2}\\,t\\right)\\,\\left(1-\\frac{t}{T}\\right) .\n",
      "$$\n",
      "\n",
      "in the limit $\\theta \\to 0$.\n"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Solution:\n",
      "\n",
      "### (a)\n",
      "\n",
      "Use the time-averaged VaR as the risk term, our cost function is,\n",
      "\n",
      "$$\n",
      "\\mathcal{C} (t)=\\mathbb{E} \\left[\\int_t^T\\, (\\eta\\,\\dot x_u^2+\\lambda\\,\\sigma\\,x_u)\\,du\\right]\n",
      "$$\n",
      "\n",
      "The corresponding HJB equation,\n",
      "$$\\frac{\\partial \\mathcal{C} }{\\partial t}+\\lambda \\sigma x_t+\\min_{v,y \\in \\mathcal{G} }\\left\\{ -v \\,\\mathcal{C} _x+\\eta\\,v^2 +\\theta\\,\\left[\\mathcal{C} (x_t-y)-\\mathcal{C} (x_t)\\right]\\right\\} =0$$\n",
      "\n",
      "We use the first order condition, \n",
      "$$v^\\star=\\frac{1}{2\\,\\eta}\\,\\mathcal{C} _x.$$\n",
      "\n",
      "And the fact that the value of $y$ that minimizes $\\left[\\mathcal{C} (x_t-y)-\\mathcal{C} (x_t)\\right]$ is obviously $y^\\star=x_t$.\n",
      "\n",
      "We could have,\n",
      "\n",
      "$$\\frac{\\partial \\mathcal{C} }{\\partial t}+\\lambda \\sigma x_t -\\frac{1}{4\\,\\eta}\\,(\\mathcal{C} _x)^2 -\\theta\\,\\mathcal{C} =0$$\n",
      "\n",
      "Plug in the ansatz $\\cC(t,x) = a(t)x^2 + b(t)x + c(t)$ into the equation, we have,\n",
      "\n",
      "$$a'(t) x^2 + b'(t) x + c'(t) + \\lambda \\, \\sigma \\, x - \\frac{(2\\,a(t)x + b(t))^2 }{4\\,\\eta} - \\theta\\,(a(t)x^2 + b(t)x + c(t))= 0$$\n",
      "\n",
      "Setting the coefficients to be zero, we have,\n",
      "\n",
      "\\begin{eqnarray*}\n",
      "a' - \\frac{a^2}{\\eta} - \\theta a = 0 \\\\\n",
      "b' - \\frac{ab}{\\eta} + \\lambda \\sigma - \\theta b = 0 \\\\\n",
      "c' - \\frac{b^2}{4\\eta} - \\theta c = 0\n",
      "\\end{eqnarray*}"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The first one is a basic Bernoulli Differential Equation, solve it and use the boundary condition $C(T,x \\neq 0) = +\\infty$, we got,\n",
      "\n",
      "$$a(t) = \\frac{\\theta \\eta}{e^{\\theta(T-t)} - 1}$$\n",
      "\n",
      "Plug it into the second formula, we have\n",
      "\n",
      "$$b(t) = \\frac{\\lambda \\sigma}{\\theta} \\frac{\\theta t + e^{\\theta(T-t)} + Const_b}{e^{\\theta(T-t)} - 1}$$\n",
      "\n",
      "where $const_b$ couldn't be determined at this point.\n",
      "\n",
      "We set $const_b = -1$ to simplify the formula, we got,\n",
      "\n",
      "$$b(t) = \\frac{\\lambda \\sigma t}{e^{\\theta(T-t)} - 1} + \\frac{\\lambda \\sigma}{\\theta}$$\n",
      "\n",
      "With some CRAZY~~~ calculation, we could somehow get what $c(t)$ should be, but we don't need it here,\n",
      "\n",
      "Hence, the optimal trading rate $v^*$ is given by the value funciton as \n",
      "\n",
      "$$\n",
      "v_t^* = \\frac{\\cC_x}{2\\eta} = \\frac{2a(t)x + b(t)}{2\\eta} = - \\dot x\n",
      "$$\n",
      "\n",
      "\n",
      "Solve the above ODE of $x_t$, we have\n",
      "\n",
      "$$\n",
      "x^\\star(t)=\\left(X-\\frac{A\\, T}{\\theta }\\right)\\,\\frac{1-e^{-\\theta\\,(T-t)} }{1-e^{-\\theta\\,T }}+\\frac{A }{\\theta }\\,(T-t)\n",
      "$$\n",
      "\n",
      "where\n",
      "\n",
      "$$A=\\frac{\\lambda\\,\\sigma}{2\\,\\eta}$$\n",
      "\n",
      "$$\n",
      "v(t)^\\star = (AT - \\theta X)\\,\\frac{e^{-\\theta\\,(T-t)} }{1-e^{-\\theta\\,T }} - \\frac{A }{\\theta }\n",
      "$$"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### (b)\n",
      "\n",
      "Using Taylor expansion, we have\n",
      "\n",
      "$$1 - e ^{-\\theta\\,(T - t)} \\approx 1 - (1 - \\theta\\,(T - t) + \\frac{(\\theta\\,(T - t))^2}{2}) = \\theta\\,(T - t) - \\frac{\\theta^2\\,(T - t)^2}{2}$$\n",
      "\n",
      "$$1 - e ^{-\\theta\\,T} \\approx 1 - (1 - \\theta\\,T + \\frac{(\\theta\\,T)^2}{2}) = \\theta\\,T - \\frac{\\theta^2\\,T^2}{2}$$\n",
      "\n",
      "Thus, we have\n",
      "\n",
      "\\begin{eqnarray*}\n",
      "\\frac{1-e^{-\\theta\\,(T-t)}}{1-e^{-\\theta\\,T }} &\\approx& \\frac{\\theta\\,(T - t) - \\frac{\\theta^2\\,(T - t)^2}{2}}{\\theta\\,T - \\frac{\\theta^2\\,T^2}{2}} = \\frac{(T-t)-\\theta\\,\\frac{(T - t)^2}{2}}{T(1 - \\frac{\\theta\\,T}{2})} &=& \\frac{T-t}{T} + \\frac{\\theta\\,T\\,(T-t) - \\theta\\,(T-t)^2}{2\\,T - \\theta\\,T^2}\n",
      "\\end{eqnarray*}\n",
      "\n",
      "\\begin{eqnarray*}\n",
      "x^\\star(t)&=&\\left(X-\\frac{A\\, T}{\\theta }\\right)\\,\\frac{1-e^{-\\theta\\,(T-t)} }{1-e^{-\\theta\\,T }}+\\frac{A }{\\theta }\\,(T-t) &\\approx& \\left(X-\\frac{A\\, T}{\\theta }\\right)\\,(\\frac{T-t}{T} + \\frac{\\theta\\,T\\,(T-t) - \\theta\\,(T-t)^2}{2\\,T - \\theta\\,T^2})+\\frac{A }{\\theta }\\,(T-t) \\\\\n",
      "&=& X\\,(1 - \\frac{t}{T}) - A\\,\\frac{T\\,(T-t) - (T - t)^2}{2 - \\theta\\,T} &=& X\\,(1 - \\frac{t}{T}) - A\\,\\frac{T\\,t - t^2}{2 - \\theta\\,T}\n",
      "\\end{eqnarray*}\n",
      "\n",
      "\\begin{eqnarray*}\n",
      "\\lim_{\\theta \\to 0}\\,(X\\,(1 - \\frac{t}{T}) - A\\,\\frac{T\\,t - t^2}{2 - \\theta\\,T}) &=& X\\,(1 - \\frac{t}{T}) - A\\,\\frac{T\\,t - t^2}{2} &=& X\\,(1 - \\frac{t}{T}) - \\frac{A\\,T}{2}\\,t\\,(1 - \\frac{t}{T}) &=& (X - \\frac{A\\,T}{2})\\,(1 - \\frac{t}{T})\n",
      "\\end{eqnarray*}"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}